﻿@using KRM.Core
@model tblEmail
@{
    var db = new KRMEntities();
    var listTicket = ViewBag.AllTickets as List<tblTicket>;
 }

@section Scripts{
            <script src="/js/mail.js"></script>
    }

    <div class="portlet box blue ">
        <div class="portlet-title">
                     <div class="caption">
                        Link email to ticket
                     </div>
                  </div>
         <div class="portlet-body form">
            <table id="LinkToTicketDTTB" class="table table-bordered table-fix tbl-selected table-striped table-hover dataTable" style="background-color:#F8F8F8">
                <thead>
                    <tr>
                        <th>Subject</th>
                        <th>Date Added</th>
                        <th>User Added</th>
                        <th>AssignedToUser</th>
                        <th>Status</th>
                        <th>Link</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in listTicket)
                    {
                        <tr onclick="LinkEmailToTicket('@Model.EmailID','@item.TicketID')" style="cursor: pointer;">
                            <td>@item.Subject</td>
                            <td>@item.DateAdded</td>
                            <td>
                                @db.tblUsers.Find(@item.AddedByUserID).Username
                            </td>
                            <td>
                                @if (@item.AssignedToUserID != null && @item.AssignedToUserID != 0)
                                {
                                     @db.tblUsers.Find(@item.AssignedToUserID).Username
                                }
                            </td>
                            <td>@db.tblTicketStatus.Find(@item.StatusID).Status</td>
                            <td><a onclick="javascript:return confirm('Link email to this ticket ?');" class="btn btn-sm blue" href="/EmailTicket/LinkEmailToTicket/?mailID=@Model.EmailID&ticketID=@item.TicketID">Link</a></td>
                        </tr>
                    }
                </tbody>
            </table>
             </div>
</div>